<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKeepStatisticsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('keep_statistics', function (Blueprint $table) {
            $table->increments('id');
            $table->date('date_time')->comment('日期');
            $table->tinyInteger('type')->comment('类型:1全服,2渠道,3区服');
            $table->smallInteger('server_id')->nullable()->comment('区服ID');
            $table->smallInteger('channel_id')->nullable()->comment('渠道ID');
            $table->integer('new_users')->comment('新增用户数量');
            $table->integer('new_roles')->comment('新增角色数量');
            $table->float('two_rate')->default(0)->comment('次日留存率');
            $table->float('three_rate')->default(0)->comment('3日留存率');
            $table->float('four_rate')->default(0)->comment('4日留存率');
            $table->float('five_rate')->default(0)->comment('5日留存率');
            $table->float('six_rate')->default(0)->comment('6日留存率');
            $table->float('seven_rate')->default(0)->comment('7日留存率');
            $table->float('fifteen_rate')->default(0)->comment('15日留存率');
            $table->float('thirty_rate')->default(0)->comment('30日留存率');
            $table->index(['server_id', 'channel_id']);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('keep_statistics');
    }
}
